import { PAGE_SIZE } from 'globalConstants';
import request from '../../../utils/request';

export function fetchList(body) {
  const pageSize = PAGE_SIZE;
  body = { ...body, pageSize };
  return request('/billing-api/a/orders', {
    method: 'GET',
    body,
  });
}

export function fetch(orderId) {
  return request(`/billing-api/a/orders/${orderId}`, {
    method: 'GET',
  });
}

// 查询退款列表
export function fetchRefunds(body) {
  const pageSize = PAGE_SIZE;
  body = { ...body, pageSize };
  return request('/billing-api/a/refunds', {
    method: 'GET',
    body,
  });
}

// 申请退款
export function refund(orderId, remark) {
  return request(`/billing-api/a/orders/${orderId}/refund`, {
    method: 'POST',
    body: {
      remark,
    },
  });
}

// 退款确认
export function confirmRefund(orderId) {
  return request(`/billing-api/a/refunds/${orderId}/confirm`, {
    method: 'POST',
  });
}

// 退款取消
export function cancelRefund(orderId) {
  return request(`/billing-api/a/refunds/${orderId}/cancel`, {
    method: 'POST',
  });
}
